namespace ScrumProject.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class SS6 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Tasks", "StoryId", "dbo.Story");
            DropIndex("dbo.Tasks", new[] { "StoryId" });
            CreateTable(
                "dbo.Posts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Content = c.String(nullable: false),
                        Time = c.DateTime(nullable: false),
                        ProjectId = c.Int(nullable: false),
                        UserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Project", t => t.ProjectId, cascadeDelete: true)
                .Index(t => t.ProjectId);
            
            CreateTable(
                "dbo.Comments",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Content = c.String(nullable: false),
                        Time = c.DateTime(nullable: false),
                        PostId = c.Int(nullable: false),
                        UserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Posts", t => t.PostId, cascadeDelete: true)
                .Index(t => t.PostId);
            
            AlterColumn("dbo.Tasks", "Description", c => c.String(nullable: false));
            AlterColumn("dbo.Tasks", "WorkRemaining", c => c.Double(nullable: false));
            AlterColumn("dbo.Tasks", "Status", c => c.Boolean(nullable: false));
            AlterColumn("dbo.Tasks", "StoryId", c => c.Int(nullable: false));
            AlterColumn("dbo.Tasks", "UserId", c => c.Int(nullable: false));
            AddForeignKey("dbo.Tasks", "StoryId", "dbo.Story", "Id", cascadeDelete: true);
            CreateIndex("dbo.Tasks", "StoryId");
        }
        
        public override void Down()
        {
            DropIndex("dbo.Comments", new[] { "PostId" });
            DropIndex("dbo.Posts", new[] { "ProjectId" });
            DropIndex("dbo.Tasks", new[] { "StoryId" });
            DropForeignKey("dbo.Comments", "PostId", "dbo.Posts");
            DropForeignKey("dbo.Posts", "ProjectId", "dbo.Project");
            DropForeignKey("dbo.Tasks", "StoryId", "dbo.Story");
            AlterColumn("dbo.Tasks", "UserId", c => c.Int());
            AlterColumn("dbo.Tasks", "StoryId", c => c.Int());
            AlterColumn("dbo.Tasks", "Status", c => c.Boolean());
            AlterColumn("dbo.Tasks", "WorkRemaining", c => c.Double());
            AlterColumn("dbo.Tasks", "Description", c => c.String());
            DropTable("dbo.Comments");
            DropTable("dbo.Posts");
            CreateIndex("dbo.Tasks", "StoryId");
            AddForeignKey("dbo.Tasks", "StoryId", "dbo.Story", "Id");
        }
    }
}
